package com.yunbiji.demo.service.impl;



import com.yunbiji.demo.dao.CnNoteActivityDao;
import com.yunbiji.demo.entity.CnNoteActivity;
import com.yunbiji.demo.service.CnNoteActivityService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CnNoteActivity)表服务实现类
 *
 * @author makejava
 * @since 2021-06-09 19:23:48
 */
@Service("cnNoteActivityService")
public class CnNoteActivityServiceImpl implements CnNoteActivityService {
    @Resource
    private CnNoteActivityDao cnNoteActivityDao;

    @Override
    public List<CnNoteActivity> queryAllByIdLimit(Integer cnActivityId, int offset, int limit) {
        return this.cnNoteActivityDao.queryAllByIdLimit(cnActivityId,offset,limit);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param cnNoteActivityId 主键
     * @return 实例对象
     */
    @Override
    public CnNoteActivity queryById(Integer cnNoteActivityId) {
        return this.cnNoteActivityDao.queryById(cnNoteActivityId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<CnNoteActivity> queryAllByLimit(int offset, int limit) {
        return this.cnNoteActivityDao.queryAllByLimit(offset, limit);
    }

    @Override
    public List<CnNoteActivity> queryAll(CnNoteActivity cnNoteActivity) {
        return this.cnNoteActivityDao.queryAll(cnNoteActivity);
    }

    /**
     * 新增数据
     *
     * @param cnNoteActivity 实例对象
     * @return 实例对象
     */
    @Override
    public CnNoteActivity insert(CnNoteActivity cnNoteActivity) {
        this.cnNoteActivityDao.insert(cnNoteActivity);
        return cnNoteActivity;
    }

    /**
     * 修改数据
     *
     * @param cnNoteActivity 实例对象
     * @return 实例对象
     */
    @Override
    public CnNoteActivity update(CnNoteActivity cnNoteActivity) {
        this.cnNoteActivityDao.update(cnNoteActivity);
        return this.queryById(cnNoteActivity.getCnNoteActivityId());
    }

    /**
     * 通过主键删除数据
     *
     * @param cnNoteActivityId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer cnNoteActivityId) {
        return this.cnNoteActivityDao.deleteById(cnNoteActivityId) > 0;
    }
}